package com.xiaoshuidi.cloud.module.rooms.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xiaoshuidi.cloud.module.rooms.pojo.RoomDeviceStairPrice;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

import java.util.List;

/**
 * <p>
 * 阶梯水电价格表 Mapper 接口
 * </p>
 *
 * @author James
 * @since 2023-06-07
 */
public interface RoomDeviceStairPriceMapper extends BaseMapper<RoomDeviceStairPrice> {
    @Select("select ${priceType} from room_sdiot_device_stair_price where ${priceRead}=0 and deleted=0 and room_device_id=${devicePriceId}")
    Double getRoomDeviceAssociationInfo(@Param("priceType") String priceType,@Param("priceRead") String priceRead,@Param("devicePriceId") Long devicePriceId);

    @Select("select * from room_sdiot_device_stair_price " +
            "where ${ew.sqlSegment} ")
    List<RoomDeviceStairPrice> getRoomDeviceAssociationList(@Param("ew") QueryWrapper<?> wrapper);

    @Select("select * from room_sdiot_device_stair_price where room_device_id=${roomDeviceId} order by cold_worter_read desc")
    List<RoomDeviceStairPrice> getPrice(@Param("roomDeviceId") Long roomDeviceId);
}
